/**
 * 随机生成字符串
 * 默认生成 32-126 也可以自定义生成范围
 * @param {number} len 
 * @param {Array<string>} scoped 
 * @returns 
 */
export function generateRandomStr(len, scoped) {
    let start = 32, end = 126;
    let result = '';
    for (let i = 0; i < len; i++) {
        if (!!!scoped) {
            let random = ~~(Math.random() * (end - start + 1) + start)
            result += String.fromCharCode(random);
        } else {
            let random = ~~(Math.random() * scoped.length);
            result += scoped[random]
        }
    }
    return result;
}